﻿/** 
 * Project:         ServerLib.Core 
 * Copyright:       Copyright (C) 2009, Rob Kennedy
 * Create Date:     2008-14-07 4:00 PM
 * Modified Date:   2008-14-07 4:00 PM
 * Comments:        2008-14-07 4:00 PM RK  Ignore SA1633
 *
 * This program is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * any later version. 
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program. If not, see <http://www.gnu.org/licenses/>. 
 */
namespace ApplicationList
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Reflection;

    /// <summary>
    /// ProgramInfo provides access to the assemblies product information
    /// </summary>
    public class ProgramInfo
    {
        /// <summary>
        /// Gets the product name
        /// </summary>
        public static string Name
        {
            get
            {
                string resultValue = string.Empty;

                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
                if(attributes != null ? attributes.Length > 0 : false)
                {
                    resultValue = ((AssemblyProductAttribute)attributes[0]).Product;
                }

                return resultValue;
            }
        }

        /// <summary>
        /// Gets the assembly copyright
        /// </summary>
        public static string Copyright
        {
            get
            {
                string resultValue = string.Empty;

                // Get all Copyright attributes on this assembly
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);

                if (attributes != null ? attributes.Length > 0 : false)
                {
                    // If there is a Copyright attribute, return its value
                    resultValue = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
                }

                return resultValue;
            }
        }

        /// <summary>
        /// Gets the assembly version
        /// </summary>
        public static string Version
        {
            get
            {
                string resultValue = string.Empty;

                // Get all Copyright attributes on this assembly
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyVersionAttribute), false);

                if (attributes != null ? attributes.Length > 0 : false)
                {
                    // If there is a Copyright attribute, return its value
                    resultValue = ((AssemblyVersionAttribute)attributes[0]).Version;
                }

                return resultValue;
            }
        }
    }
}
